<?php
/**
 * Created by IntelliJ IDEA.
 * User: HXL
 * Date: 2018/5/21
 * Time: 11:29
 */
namespace app\order\model;

use think\Db;
class Depts extends BaseModel{
    protected $tableName = 'ari_depts';

    public function search($where){
        $search = Db::table($this->tableName)->where($where)->select();
        return $search;
    }
    /**
     * 查询部门下是否存在用户
     */
    public function uidExist($tableAdmin, $where){
        $find = Db::table($this->tableName)->join($tableAdmin, $tableAdmin.'.de_id='.$this->tableName.'.de_id')->where($where)->find();
        return $find;
    }

    public function searchLike($search){
        $num = 10;
        $count = Db::table($this->tableName)->where('dept_name', 'like', "%$search%")->whereOr('description', 'like', "%$search%")
            ->count();
        $data = Db::table($this->tableName)->where('dept_name', 'like', "%$search%")->whereOr('description', 'like', "%$search%")
            ->paginate($num, $count, ['query' => request()->param()]);
        return $data;
    }
}